package io.itit.ecp.admin.server.service;

import icu.mhb.mybatisplus.plugln.base.service.JoinIService;
import io.itit.ecp.admin.server.entity.CarbonSinkDataEntity;
import io.itit.ecp.admin.server.entity.extend.CarbonSinkDataExtEntity;
import io.itit.grass.common.server.dto.ParamDto;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *
 * @Author：Roy
 * @Description：碳汇数据服务类
 * @Date：Create by 2023-12-01 10:45:08
 */
public interface ICarbonSinkDataService extends JoinIService<CarbonSinkDataEntity> {

    CarbonSinkDataExtEntity sum(ParamDto dto);

    List<CarbonSinkDataExtEntity> sumGroupType(ParamDto dto);

    List<CarbonSinkDataExtEntity> sumGroupSolidifyDate(ParamDto dto);

    List<CarbonSinkDataExtEntity> sumGroupSolidifyDateAndType(ParamDto dto);

    /**
     * 碳汇因子值更新时同步重新计算相关联能源数据
     *
     * @param type         植被类型(1:休闲绿地,2:道路绿地,3:居住区绿地,4:单位附属绿地)
     * @param solidifyDate 数据日期
     * @param factor       因子值
     */
    boolean causeFactorUpdate(String type, Date solidifyDate, BigDecimal factor);

    default BigDecimal computeCarbonReductionTotal(String sceneProjectId, LocalDateTime start, LocalDateTime end) {
        return computeCarbonReductionTotal(sceneProjectId, null, null, start, end);
    }

    BigDecimal computeCarbonReductionTotal(String sceneProjectId, String sceneEdificeId, String sceneFloorId, LocalDateTime start, LocalDateTime end);

    default BigDecimal computeCarbonReductionTotal(String sceneProjectId, Date start, Date end) {
        return computeCarbonReductionTotal(sceneProjectId, null, null, start, end);
    }

    BigDecimal computeCarbonReductionTotal(String sceneProjectId, String sceneEdificeId, String sceneFloorId, Date start, Date end);
}